# import requests

#
#
import requests


class IRHMApi:
    #封装登录接口
    @classmethod
    def ihrm_login_api(cls,login_boay):
        login_url = "http://ihrm2-test.itheima.net/api/sys/login"
        login_header = {"Content-Type": "application/json"}
        login_resp = requests.post(url=login_url, headers=login_header, json=login_boay)
        return login_resp
    # 封装员工添加接口
    @classmethod
    def ihrm_add_emp(cls,token,add_emp_body):
        add_emp_url = " http://ihrm2-test.itheima.net/api/sys/user"
        add_emp_header = {"Content-Type": "application/json", "Authorization": token}
        add_emp_resp = requests.post(url=add_emp_url, headers=add_emp_header, json=add_emp_body)
        return add_emp_resp
    #封装查询接口
    @classmethod
    def ihrm_qurey_emp(cls,emp_id,token):
        query_emp_url = "http://ihrm2-test.itheima.net/api/sys/user/"+emp_id
        query_emp_header = {"Authorization": token}
        query_emp_resp = requests.get(url=query_emp_url, headers=query_emp_header)
        return query_emp_resp
    # 封装员工修改接口
    @classmethod
    def ihrm_modify_emp(cls,emp_id,token,modify_emp_body):
        modify_emp_url = "http://ihrm2-test.itheima.net/api/sys/user/"+emp_id
        modify_emp_header = {"Content-Type": "application/json",
                             "Authorization":token }

        modify_emp_resp = requests.put(url=modify_emp_url, headers=modify_emp_header, json=modify_emp_body)
        return modify_emp_resp
    #员工删除接口
    @classmethod
    def hirm_del_emp(cls,emp_id,token):
        del_emp_url = "http://ihrm2-test.itheima.net/api/sys/user/"+emp_id
        del_emp_header = {"Authorization": token}
        del_emp_resp = requests.delete(url=del_emp_url, headers=del_emp_header)
        return del_emp_resp
# if __name__ == '__main__':
#     token='2604e179-245f-4722-a850-0d596ff15cf8'
#     body={
#          "username": "小猪佩奇",
#          "mobile": "15996895645",
#          "workNumber": "22"}
#     resp=IRHMApi.ihrm_add_emp(token,body)
#     print("resp=",resp.json())
